/**
 * 
 */
package GUI;

import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Toolkit;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JSplitPane;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import javax.swing.border.BevelBorder;
import java.awt.Font;
import java.awt.Color;

import javax.swing.DefaultCellEditor;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EtchedBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

import java.util.Vector;
import java.awt.Point;
import java.awt.Dimension;
import javax.swing.ListSelectionModel;
import javax.swing.JLabel;
import java.awt.event.KeyEvent;
import javax.swing.BoxLayout;
import java.awt.FlowLayout;
import javax.swing.JTabbedPane;
import javax.swing.JList;
import javax.swing.JButton;
import javax.swing.JSeparator;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.JComboBox;

/**
 * @author Quique
 *
 */
public class FacturacionGrafica extends JFrame implements MouseListener,ChangeListener,ActionListener {

	private JPanel jContentPane = null;
	private JSplitPane jSPFacturacion = null;
	private JPanel jPDatosFactura = null;
	private JScrollPane jSPDatosFactura = null;
	private JPanel jPPedidosConsumiciones = null;
	private JTabbedPane jTabbedPane = null;
	private JScrollPane jSPConsumiciones = null;
	private JTable jTConsumiciones = null;
	private MyEstadoTableModel mdtm = null;  //  @jve:decl-index=0:visual-constraint="843,312"
	private JButton jBGenerarFactura = null;
	private JPanel jPFactura = null;
	private JLabel jLNumFactura = null;
	private JSeparator jSeparator1 = null;
	private JSeparator jSeparator2 = null;
	private JLabel jLFecha = null;
	private JTextField jTFNombreCliente = null;
	private JLabel jLNombreCliente = null;
	private JLabel jLModoPago = null;
	private JComboBox jCBModoPago = null;
	private JLabel jLTipoDescuento = null;
	private JComboBox jCBTipoDescuento = null;
	private JLabel jLCantidadADescontar = null;
	private JTextField jTFCantidadADescontar = null;
	private JLabel jLRestaurante = null;
	private JLabel jLCIF = null;
	private JLabel jLTelefono = null;
	private JLabel jlDireccion = null;
	private JLabel jLTotal = null;
	private JLabel jLTDescuento = null;
	private JLabel jLTIVA = null;
	private JLabel jLTotalAPagar = null;
	private JSeparator jSeparator3 = null;
	private JSeparator jSeparator4 = null;
	private JTextField jTFTotal = null;
	private JTextField jTFDescuento = null;
	private JTextField jTFTotalSinIVA = null;
	private JTextField jTFIVA = null;
	private JTextField jTFTotalAPagar = null;
	private JLabel jLTMenos = null;
	private JLabel jLTMas = null;
	private JScrollPane jSPPedidos = null;
	private JTable jTPedidos = null;
	private JButton jBActualizar = null;
	/**
	 * @throws HeadlessException
	 */
	public FacturacionGrafica() throws HeadlessException {
		initialize();
	}
	/**
	 * This method initialize			
	 * 
	 */
	private void initialize() {
		this.setTitle("Subsistema de gestión deFacturación");
		this.setPreferredSize(new Dimension(800, 600));
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setMinimumSize(new Dimension(800, 600));
		this.setMaximumSize(new Dimension(800, 600));
		this.setLocation(new Point(50, 50));
		this.setContentPane(getJContentPane());
		this.setVisible(true);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/iconos/table.png")));
	}


	/* (sin Javadoc)
	 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
	 */
	public void mouseClicked(MouseEvent e) {
		// TODO Apéndice de método generado automáticamente

	}

	/* (sin Javadoc)
	 * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
	 */
	public void mouseEntered(MouseEvent e) {
		// TODO Apéndice de método generado automáticamente

	}

	/* (sin Javadoc)
	 * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
	 */
	public void mouseExited(MouseEvent e) {
		// TODO Apéndice de método generado automáticamente

	}

	/* (sin Javadoc)
	 * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
	 */
	public void mousePressed(MouseEvent e) {
		// TODO Apéndice de método generado automáticamente

	}

	/* (sin Javadoc)
	 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
	 */
	public void mouseReleased(MouseEvent e) {
		// TODO Apéndice de método generado automáticamente

	}

	/* (sin Javadoc)
	 * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
	 */
	public void stateChanged(ChangeEvent e) {
		// TODO Apéndice de método generado automáticamente

	}
	/**
	 * This method initializes jContentPane	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getJSPCocina(), BorderLayout.CENTER);
		}
		return jContentPane;
	}
	/**
	 * This method initializes jSPCocina	
	 * 	
	 * @return javax.swing.JSplitPane	
	 */
	private JSplitPane getJSPCocina() {
		if (jSPFacturacion == null) {
			jSPFacturacion = new JSplitPane();
			jSPFacturacion.setDividerSize(10);
			jSPFacturacion.setLeftComponent(getJPDatosFactura());
			jSPFacturacion.setRightComponent(getJPPedidosConsumiciones());
			jSPFacturacion.setDividerLocation(400);
		}
		return jSPFacturacion;
	}
	/**
	 * This method initializes jPDatosFactura	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPDatosFactura() {
		if (jPDatosFactura == null) {
			jPDatosFactura = new JPanel();
			jPDatosFactura.setLayout(new BorderLayout());
			jPDatosFactura.setBorder(BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED), "DATOS FACTURA:", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPDatosFactura.add(getJSPDatosFactura(), BorderLayout.CENTER);
			jPDatosFactura.add(getJBGenerarFactura(), BorderLayout.SOUTH);
		}
		return jPDatosFactura;
	}
	/**
	 * This method initializes jSPDatosFactura	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJSPDatosFactura() {
		if (jSPDatosFactura == null) {
			jSPDatosFactura = new JScrollPane();
			jSPDatosFactura.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
			jSPDatosFactura.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
			jSPDatosFactura.setViewportView(getJPFactura());
			jSPDatosFactura.setViewportBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		}
		return jSPDatosFactura;
	}
	/**
	 * This method initializes jPPedidosConsumiciones	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPPedidosConsumiciones() {
		if (jPPedidosConsumiciones == null) {
			TitledBorder titledBorder = BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED), "DISPONIBILIDAD DE LOS PRODUCTOS:", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51));
			titledBorder.setTitle("PEDIDOS Y CONSUMICIONES:");
			jPPedidosConsumiciones = new JPanel();
			jPPedidosConsumiciones.setLayout(new BorderLayout());
			jPPedidosConsumiciones.setPreferredSize(new Dimension(400, 600));
			jPPedidosConsumiciones.setBorder(titledBorder);
			jPPedidosConsumiciones.add(getJTabbedPane(), BorderLayout.CENTER);
			jPPedidosConsumiciones.add(getJBActualizar(), BorderLayout.SOUTH);
		}
		return jPPedidosConsumiciones;
	}
	/**
	 * This method initializes jTabbedPane	
	 * 	
	 * @return javax.swing.JTabbedPane	
	 */
	private JTabbedPane getJTabbedPane() {
		if (jTabbedPane == null) {
			jTabbedPane = new JTabbedPane();
			jTabbedPane.setPreferredSize(new Dimension(0, 0));
			jTabbedPane.addTab("PEDIDOS", new ImageIcon(getClass().getResource("/iconos/table_edit.png")), getJSPPedidos(), null);
			jTabbedPane.addTab("CONSUMICIONES", new ImageIcon(getClass().getResource("/iconos/table_edit.png")), getJSPConsumiciones(), null);
		}
		return jTabbedPane;
	}
	/**
	 * This method initializes jSPConsumiciones	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJSPConsumiciones() {
		if (jSPConsumiciones == null) {
			jSPConsumiciones = new JScrollPane();
			jSPConsumiciones.setViewportView(getJTConsumiciones());
		}
		return jSPConsumiciones;
	}
	/**
	 * This method initializes jTConsumiciones	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private JTable getJTConsumiciones() {
		if (jTConsumiciones == null)
		{
			ConsumicionesTableModel ctm=new ConsumicionesTableModel();
			jTConsumiciones = new JTable(ctm);
			jTConsumiciones.setAutoCreateColumnsFromModel(true);
			jTConsumiciones.setShowGrid(true);
			jTConsumiciones.setCellSelectionEnabled(false);
			jTConsumiciones.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
			jTConsumiciones.setRowSelectionAllowed(true);
						
			TableColumn column = null;
			for (int i = 0; i < 3; i++) {
			    column = jTConsumiciones.getColumnModel().getColumn(i);
			    switch(i)
			    {
			    case 0: column.setPreferredWidth(260);break;
			    case 1: column.setPreferredWidth(70);break;			    
			    case 2: column.setPreferredWidth(70);break;
			    }			    
			}			
			
		}
		return jTConsumiciones;
	}
	/**
	 * This method initializes jBGenerarFactura	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJBGenerarFactura() {
		if (jBGenerarFactura == null) {
			jBGenerarFactura = new JButton();
			jBGenerarFactura.setText("GENERAR FACTURA ...");
			jBGenerarFactura.setActionCommand("Generar");
			jBGenerarFactura.setIcon(new ImageIcon(getClass().getResource("/iconos/accept.png")));
			jBGenerarFactura.addActionListener(this);
		}
		return jBGenerarFactura;
	}
	/**
	 * This method initializes jPFactura	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPFactura() {
		if (jPFactura == null) {
			jLTMas = new JLabel();
			jLTMas.setBounds(new Rectangle(131, 433, 12, 20));
			jLTMas.setText("+");
			jLTMas.setPreferredSize(new Dimension(93, 20));
			jLTMenos = new JLabel();
			jLTMenos.setBounds(new Rectangle(132, 362, 10, 20));
			jLTMenos.setText("_");
			jLTMenos.setPreferredSize(new Dimension(93, 20));
			jLTotalAPagar = new JLabel();
			jLTotalAPagar.setBounds(new Rectangle(12, 482, 101, 20));
			jLTotalAPagar.setText("TOTAL A PAGAR:");
			jLTotalAPagar.setPreferredSize(new Dimension(93, 20));
			jLTIVA = new JLabel();
			jLTIVA.setBounds(new Rectangle(12, 452, 93, 20));
			jLTIVA.setText("I.V.A.:");
			jLTIVA.setPreferredSize(new Dimension(93, 20));
			jLTDescuento = new JLabel();
			jLTDescuento.setBounds(new Rectangle(12, 382, 93, 20));
			jLTDescuento.setText("DESCUENTO:");
			jLTDescuento.setPreferredSize(new Dimension(93, 20));
			jLTotal = new JLabel();
			jLTotal.setBounds(new Rectangle(12, 354, 93, 20));
			jLTotal.setText("TOTAL:");
			jLTotal.setPreferredSize(new Dimension(93, 20));
			jlDireccion = new JLabel();
			jlDireccion.setBounds(new Rectangle(12, 162, 362, 16));
			jlDireccion.setText("DIRECCIÓN: C\\jeje");
			jLTelefono = new JLabel();
			jLTelefono.setBounds(new Rectangle(12, 132, 131, 16));
			jLTelefono.setText("TELÉFONO: 999533545");
			jLCIF = new JLabel();
			jLCIF.setBounds(new Rectangle(12, 102, 88, 16));
			jLCIF.setText("CIF: C12313212");
			jLRestaurante = new JLabel();
			jLRestaurante.setBounds(new Rectangle(12, 73, 361, 16));
			jLRestaurante.setText("NOMBRE RESTAURANTE: DONDE SEA");
			jLCantidadADescontar = new JLabel();
			jLCantidadADescontar.setText("CANTIDAD A DESCONTAR:");
			jLCantidadADescontar.setSize(new Dimension(160, 20));
			jLCantidadADescontar.setLocation(new Point(12, 302));
			jLTipoDescuento = new JLabel();
			jLTipoDescuento.setPreferredSize(new Dimension(103, 20));
			jLTipoDescuento.setLocation(new Point(12, 272));
			jLTipoDescuento.setSize(new Dimension(111, 20));
			jLTipoDescuento.setText("TIPO DESCUENTO:");
			jLModoPago = new JLabel();
			jLModoPago.setPreferredSize(new Dimension(93, 20));
			jLModoPago.setLocation(new Point(12, 242));
			jLModoPago.setSize(new Dimension(103, 20));
			jLModoPago.setText("MODO DE PAGO:");
			jLNombreCliente = new JLabel();
			jLNombreCliente.setText("NOMBRE CLIENTE:");
			jLNombreCliente.setSize(new Dimension(108, 20));
			jLNombreCliente.setLocation(new Point(12, 212));
			jLFecha = new JLabel();
			jLFecha.setText("FECHA: 14/05/2007");
			jLFecha.setSize(new Dimension(105, 20));
			jLFecha.setLocation(new Point(12, 42));
			jLNumFactura = new JLabel();
			jLNumFactura.setText("FACTURA NÚMERO: 2007-0000001");
			jLNumFactura.setSize(new Dimension(193, 20));
			jLNumFactura.setLocation(new Point(12, 12));
			jPFactura = new JPanel();
			jPFactura.setLayout(null);
			jPFactura.add(jLNumFactura, null);
			jPFactura.add(jLFecha, null);
			jPFactura.add(jLRestaurante, null);
			jPFactura.add(jLCIF, null);
			jPFactura.add(jLTelefono, null);
			jPFactura.add(jlDireccion, null);
			jPFactura.add(getJSeparator1(), null);
			jPFactura.add(getJTFNombreCliente(), null);
			jPFactura.add(jLNombreCliente, null);
			jPFactura.add(jLModoPago, null);
			jPFactura.add(getJCBModoPago(), null);
			jPFactura.add(jLTipoDescuento, null);
			jPFactura.add(getJCBTipoDescuento(), null);
			jPFactura.add(jLCantidadADescontar, null);
			jPFactura.add(getJTFCantidadADescontar(), null);
			jPFactura.add(getJSeparator2(), null);
			jPFactura.add(jLTotal, null);
			jPFactura.add(jLTDescuento, null);
			jPFactura.add(jLTIVA, null);
			jPFactura.add(jLTotalAPagar, null);
			jPFactura.add(getJSeparator3(), null);
			jPFactura.add(getJSeparator4(), null);
			jPFactura.add(getJTFTotal(), null);
			jPFactura.add(getJTFDescuento(), null);
			jPFactura.add(getJTFTotalSinIVA(), null);
			jPFactura.add(getJTFIVA(), null);
			jPFactura.add(getJTFTotalAPagar(), null);
			jPFactura.add(jLTMenos, null);
			jPFactura.add(jLTMas, null);
		}
		return jPFactura;
	}
	/**
	 * This method initializes jSeparator1	
	 * 	
	 * @return javax.swing.JSeparator	
	 */
	private JSeparator getJSeparator1() {
		if (jSeparator1 == null) {
			jSeparator1 = new JSeparator();
			jSeparator1.setPreferredSize(new Dimension(400, 2));
			jSeparator1.setSize(new Dimension(391, 8));
			jSeparator1.setLocation(new Point(-8, 192));
		}
		return jSeparator1;
	}
	/**
	 * This method initializes jSeparator2	
	 * 	
	 * @return javax.swing.JSeparator	
	 */
	private JSeparator getJSeparator2() {
		if (jSeparator2 == null) {
			jSeparator2 = new JSeparator();
			jSeparator2.setLocation(new Point(-8, 342));
			jSeparator2.setSize(new Dimension(390, 8));
		}
		return jSeparator2;
	}
	/**
	 * This method initializes jTFNombreCliente	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTFNombreCliente() {
		if (jTFNombreCliente == null) {
			jTFNombreCliente = new JTextField();
			jTFNombreCliente.setText("Fulanito de Tal");
			jTFNombreCliente.setBounds(new Rectangle(132, 212, 241, 20));
		}
		return jTFNombreCliente;
	}
	/**
	 * This method initializes jCBModoPago	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJCBModoPago() {
		if (jCBModoPago == null) {
			jCBModoPago = new JComboBox();
			jCBModoPago.setMaximumRowCount(2);
			jCBModoPago.setSize(new Dimension(240, 20));
			jCBModoPago.setLocation(new Point(132, 242));
			jCBModoPago.addItem("EFECTIVO");
			jCBModoPago.addItem("TARJETA");
		}
		return jCBModoPago;
	}
	/**
	 * This method initializes jCBTipoDescuento	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJCBTipoDescuento() {
		if (jCBTipoDescuento == null) {
			jCBTipoDescuento = new JComboBox();
			jCBTipoDescuento.setMaximumRowCount(3);
			jCBTipoDescuento.setSize(new Dimension(241, 20));
			jCBTipoDescuento.setLocation(new Point(132, 272));
			jCBTipoDescuento.addItem("NINGUNO");
			jCBTipoDescuento.addItem("PORCENTUAL");
			jCBTipoDescuento.addItem("ABSOLUTO");
		}
		return jCBTipoDescuento;
	}
	/**
	 * This method initializes jTFCantidadADescontar	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTFCantidadADescontar() {
		if (jTFCantidadADescontar == null) {
			jTFCantidadADescontar = new JTextField();
			jTFCantidadADescontar.setText("0 €");
			jTFCantidadADescontar.setSize(new Dimension(189, 20));
			jTFCantidadADescontar.setHorizontalAlignment(JTextField.TRAILING);
			jTFCantidadADescontar.setLocation(new Point(182, 302));
		}
		return jTFCantidadADescontar;
	}
	/**
	 * This method initializes jSeparator3	
	 * 	
	 * @return javax.swing.JSeparator	
	 */
	private JSeparator getJSeparator3() {
		if (jSeparator3 == null) {
			jSeparator3 = new JSeparator();
			jSeparator3.setBounds(new Rectangle(122, 408, 231, 10));
		}
		return jSeparator3;
	}
	/**
	 * This method initializes jSeparator4	
	 * 	
	 * @return javax.swing.JSeparator	
	 */
	private JSeparator getJSeparator4() {
		if (jSeparator4 == null) {
			jSeparator4 = new JSeparator();
			jSeparator4.setBounds(new Rectangle(122, 472, 230, 10));
		}
		return jSeparator4;
	}
	/**
	 * This method initializes jTFTotal	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTFTotal() {
		if (jTFTotal == null) {
			jTFTotal = new JTextField();
			jTFTotal.setBounds(new Rectangle(142, 354, 211, 20));
			jTFTotal.setHorizontalAlignment(JTextField.TRAILING);
			jTFTotal.setEditable(false);
			jTFTotal.setText("0 €");
		}
		return jTFTotal;
	}
	/**
	 * This method initializes jTFDescuento	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTFDescuento() {
		if (jTFDescuento == null) {
			jTFDescuento = new JTextField();
			jTFDescuento.setBounds(new Rectangle(142, 382, 211, 20));
			jTFDescuento.setEditable(false);
			jTFDescuento.setHorizontalAlignment(JTextField.TRAILING);
			jTFDescuento.setText("0 €");
		}
		return jTFDescuento;
	}
	/**
	 * This method initializes jTFTotalSinIVA	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTFTotalSinIVA() {
		if (jTFTotalSinIVA == null) {
			jTFTotalSinIVA = new JTextField();
			jTFTotalSinIVA.setBounds(new Rectangle(142, 412, 211, 20));
			jTFTotalSinIVA.setEditable(false);
			jTFTotalSinIVA.setHorizontalAlignment(JTextField.TRAILING);
			jTFTotalSinIVA.setText("0 €");
		}
		return jTFTotalSinIVA;
	}
	/**
	 * This method initializes jTFIVA	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTFIVA() {
		if (jTFIVA == null) {
			jTFIVA = new JTextField();
			jTFIVA.setBounds(new Rectangle(142, 442, 211, 20));
			jTFIVA.setEditable(false);
			jTFIVA.setHorizontalAlignment(JTextField.TRAILING);
			jTFIVA.setText("0 €");
		}
		return jTFIVA;
	}
	/**
	 * This method initializes jTFTotalAPagar	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTFTotalAPagar() {
		if (jTFTotalAPagar == null) {
			jTFTotalAPagar = new JTextField();
			jTFTotalAPagar.setBounds(new Rectangle(142, 482, 212, 20));
			jTFTotalAPagar.setEditable(false);
			jTFTotalAPagar.setHorizontalAlignment(JTextField.TRAILING);
			jTFTotalAPagar.setText("0 €");
		}
		return jTFTotalAPagar;
	}
	/**
	 * This method initializes jSPPedidos	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJSPPedidos() {
		if (jSPPedidos == null) {
			jSPPedidos = new JScrollPane();
			jSPPedidos.setViewportView(getJTPedidos());
		}
		return jSPPedidos;
	}
	/**
	 * This method initializes jTPedidos	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private JTable getJTPedidos() {
		if (jTPedidos == null) 
		{
			PedidosTableModel ptm=new PedidosTableModel();
			jTPedidos = new JTable(ptm);
			jTPedidos.setAutoCreateColumnsFromModel(true);
			jTPedidos.setShowGrid(true);
			jTPedidos.setCellSelectionEnabled(false);
			jTPedidos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
			jTPedidos.setRowSelectionAllowed(true);
					
			TableColumn column = null;
			for (int i = 0; i < 2; i++) {
			    column = jTPedidos.getColumnModel().getColumn(i);
			    switch(i)
			    {
			    case 0: column.setPreferredWidth(270);break;
			    case 1: column.setPreferredWidth(130);break;			    
			    }			    
			}		
		}
		return jTPedidos;
	}
	/**
	 * This method initializes jBActualizar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJBActualizar() {
		if (jBActualizar == null) {
			jBActualizar = new JButton();
			jBActualizar.setText("ACTUALIZAR");
			jBActualizar.setIcon(new ImageIcon(getClass().getResource("/iconos/arrow_refresh.png")));
		}
		return jBActualizar;
	}
	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand().equals("Generar"))
		{
			JOptionPane.showMessageDialog(this,
					"Se va a generar una factura y sus dos copias correspondientes con los datos introducidos:\n¿Desea continuar?", 
					"Confirmación de Factura", 
					JOptionPane.QUESTION_MESSAGE);
			
		}
		
	}

}

class ConsumicionesTableModel extends AbstractTableModel
{
	String[] columnNames = {"PRODUCTO","CANTIDAD","PRECIO"};
	
	Object[][] data = {
			{"Sopa de ajo",2,4.50},
			{"Filete Ternera",1,8},
			{"Spaghetti Carbonara",1,3.75}
		};	

    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return data.length;
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data[row][col];
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    public boolean isCellEditable(int row, int col) 
    {
        return false;
    }

    /*
     * Don't need to implement this method unless your table's
     * data can change.
     */
    public void setValueAt(Object value, int row, int col) {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
    }
    
}

class PedidosTableModel extends AbstractTableModel
{
	String[] columnNames = {"MESAS","NUM COMENSALES"};
	
	Object[][] data = {
			{"1,2,3",12},
			{"5",2},
			{"7",4},
			{"10",3}
		};	

    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return data.length;
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data[row][col];
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    public boolean isCellEditable(int row, int col) 
    {
        return false;
    }

    /*
     * Don't need to implement this method unless your table's
     * data can change.
     */
    public void setValueAt(Object value, int row, int col) {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
    }
    
}




